package com.alien.admin.modules.container.util;

import com.alien.admin.utils.DateUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class ChartUtils {

    public static void fillJvmValOfDt(List<Map<String, String>> resultList, Long beginTime, Long endTIme) {
        List<String> allDtList = DateUtil.getMiddleDateTime(beginTime, endTIme);
        if (resultList.size() < allDtList.size()) {
            List<String> dtList = resultList.stream().map(m -> m.get("dt")).collect(Collectors.toList());
            allDtList.removeAll(dtList);
            allDtList.forEach(d -> {
                Map<String, String> tempMap = new HashMap<>();
                tempMap.put("dt", d);
                tempMap.put("value", "0.00");
                resultList.add(tempMap);
            });
        }
    }

    public static void fillJvmValOfDt(Map<String, List<Map<String, String>>> resultMap, Long beginTime, Long endTIme) {
        resultMap.forEach((k, v) -> {
            fillJvmValOfDt(v, beginTime, endTIme);
        });
    }
}
